import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import render from '@dfeidao/atom-nodejs/render/render';
import p001 from './p001';
import p003 from './p003';
import sub_hours from '@dfeidao/atom-nodejs/dt/sub-hours';
import format from '@dfeidao/atom-web/dt/format';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import get_field from '@dfeidao/atom-nodejs/data/get-field';
import p002 from './p002';
export default async function na001(fd: IFeidaoAiNodejsComponent) {

	//获取当前的时间start
	const nowTime7 = new Date().getTime();
	//获取当前的时间end
	//获取过去7天的时间start
	const lsa6 = nowTime7 - (24 * 3600000);
	const lsa5 = lsa6 - (24 * 3600000);
	const lsa4 = lsa5 - (24 * 3600000);
	const lsa3 = lsa4 - (24 * 3600000);
	const lsa2 = lsa3 - (24 * 3600000);
	const lsa1 = lsa2 - (24 * 3600000);
	const s1 = format(lsa6, 0);
	const s2 = format(lsa5, 0);
	const s3 = format(lsa4, 0);
	const s4 = format(lsa3, 0);
	const s5 = format(lsa2, 0);
	const s6 = format(lsa1, 0);
	const s7 = format(nowTime7, 0);

	//获取过去7天的时间end
	const arr = Array();
	const ass = Array();
	const asp = Array();
	const ads = Array();
	asp[0] = s7;
	asp[1] = s1;
	asp[2] = s2;
	asp[3] = s3;
	asp[4] = s4;
	asp[5] = s5;
	asp[6] = s6;
	arr[0] = [lsa1, lsa2, lsa3, lsa4, lsa5, lsa6, nowTime7];
	ass[0] = [s7, s1, s2, s3, s4, s5, s6];
	ads[0] = [0, 1, 2, 3, 4];


	const res = await nodejs<{ arwr: Array<{}> }>(fd.data.actionid, fd.data.sessionid, 'test-web/zj-000001/s002', {
		filter: {
			create_time: arr[0]
		}
	});
	const res1 = await nodejs<{ ofo: Array<{}> }>(fd.data.actionid, fd.data.sessionid, 'test-web/zj-000001/s003', {
		filter: {
			startime:lsa1,
			endtime:nowTime7,
			work_order_status: ads[0]
		}
	});
	////////



	const tol = [];
	for (let i = 0; i < res.arwr.length; i++) {
		tol.push(res.arwr[i]);

	}
	const lplp = await get_field(res.arwr, 'create_time');


	const asdfsf = ass[0].s1;
	//console.log("res",res.arwr[5].count);
	const saf = Array();
	const assdf = Array();

	// for (let i = 0; i < res.arwr.length; i++) {

	saf[0] = [{ time: asp[0], count: res.arwr[5] }, { time: asp[1], count: res.arwr[4] }, { time: asp[2], count: res.arwr[3] }
		, { time: asp[3], count: res.arwr[2] }, { time: asp[4], count: res.arwr[1] }, { time: asp[5], count: res.arwr[0] }, { time: asp[6], count: res.arwr[0] }]

	assdf[0] = [{ count: res1.ofo[0] }, { count: res1.ofo[1] }, { count: res1.ofo[2] }, { count: res1.ofo[3] }, { count: res1.ofo[4] }];
	//}

	const value = '[{"time":"1997/12/09","工单数量":"2"}]';

	render(fd.data.node, saf[0], p001, "p001");
	render(fd.data.node, assdf[0], p003, "p003");

}
